import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-03-16
 * Time:19:35
 */

class SimpleGui3C implements ActionListener{
        JFrame frame;
     public void go()
     {
         frame=new JFrame();
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         JButton fw=new JButton("选择颜色");
         fw.addActionListener(this);
         MtDrawPane1 drawPanel =new MtDrawPane1();
         frame.getContentPane().add(BorderLayout.SOUTH,fw);

         frame.getContentPane().add(BorderLayout.CENTER,drawPanel);
         frame.setSize(2000,2000);
         frame.setVisible(true);
     }
    public void actionPerformed(ActionEvent e) {
        frame.repaint();
    }
}
class MtDrawPane1 extends JPanel
{
    public void paintComponent(Graphics g)
    {
        Graphics2D gh=(Graphics2D)g;
        int red=(int)(Math.random()%255);
        int green=(int)(Math.random()%255);
        int blue=(int)(Math.random()%255);
        Color statColor =new Color(red,green,blue);
        GradientPaint fei=new GradientPaint(370,370,statColor,550,550,Color.black);

        gh.setPaint(fei);
        gh.fillOval(270,270,300,300);
    }
}
public class Text {
    public static void main(String[] args) {
        SimpleGui3C kk=new SimpleGui3C();
        kk.go();;
    }


}
